<template>
  <div class="systemInfo" id="systemInfo">
    <!-- 表格展示部分 -->
    <div class="table">
      <div class="data">
        <ul>
          <li class="left-li" v-for="(item, index) in headerData" :key="index">
            {{ item }}
          </li>
        </ul>
        <ul class="table-right">
          <li class="productName">
            <span>华能内容平台</span>
            <!-- <span>{{ tableData.productName }}</span> -->
            <!-- <span @click="goWebsite"
              ><img src="../../../assets/imgs/authorization.png" alt=""
            /></span> -->
          </li>
          <li>{{ tableData.productVersion }}</li>
          <li>{{ tableData.userCompanyName }}</li>
          <li>
            {{ tableData.copyright }}
            <a @click="openWeb()">{{ tableData.homePage }}</a>
          </li>
          <li>麒麟</li>
          <!-- <li>{{ tableData.osName }}</li> -->
          <li>{{ tableData.jdkVersion }}</li>
          <li>greatsql</li>
          <!-- <li>{{ tableData.dbType }}</li> -->
          <li>{{ tableData.dpAddress }}</li>
          <li>{{ tableData.dbPort }}</li>
          <li>{{ tableData.dbName }}</li>
        </ul>
      </div>
    </div>
    <base-modal
      :width="modAlProps.width"
      :isVisible="isVisible"
      :title="modAlProps.title"
      :buttons="buttons"
      cancleText="稍后处理"
      @handleOk="buttonMessage"
      @handleCancle="isVisible = false"
      class="site_modal"
      v-if="isVisible"
    >
      <template v-slot:body>
        <div class="model">
          <div class="logo"><img src="../../../assets/imgs/authorization2.png" alt="" /></div>
          <div class="info">
            <div class="title">JEECMS {{ versions }}</div>
            <div class="item">
              授权号:<span>{{ authorizationNumber }}</span>
            </div>
            <div class="item">到期时间: <span>永久授权</span></div>
            <div class="item">购买授权请访问: <a @click="openWeb">www.jeecms.com</a></div>
          </div>
        </div>
      </template>
    </base-modal>
  </div>
</template>
<script lang="ts" setup>
import { ref, reactive, computed, onMounted, nextTick, createVNode } from "vue";
import { getTableScroll } from "@/components/table/tableConfig/table";
import { useRoute, useRouter } from "vue-router";
import request from "@/api/index";
import { scrollType, modeProp, detailDataItemType } from "@/type.d";
import { message } from "ant-design-vue";
import baseModal from "@/components/modal/baseModal.vue";

// type
type configDataType = {
  records: any[];
};
interface dataSourceType {
  [propName: string]: any;
}
interface FormState {
  tagWord: dataSourceType;
  password: string;
  remember: boolean;
}

//data
//表格数据
const headerData = reactive<String[]>([
  "软件名称",
  "版本号",
  "用户单位",
  "版权所有",
  "操作系统",
  "JDK版本",
  "数据库类型",
  "数据库链接地址",
  "数据库端口",
  "数据库名称",
]);
const tableData = ref<dataSourceType>({});
// 模态框数据
const isVisible = ref<boolean>(false);
const modAlProps: modeProp = reactive({
  width: "M",
  title: "授权信息",
});
const buttons = [
  {
    text: "前往购买",
    "html-type": "submit",
  },
];
const authorizationNumber = ref<any>("");
const versions = ref<any>("");
//methods
// 获取系统信息列表
const getTableData = () => {
  request
    .systemInfo()
    .then((res: any) => {
      tableData.value = res || {};
      // console.log(tableData.value);
    })
    .catch((err: any) => {
      throw new Error(err);
    });
};
// 获取授权信息
const getLicenseData = () => {
  request
    .getLicense()
    .then((res: any) => {
      // console.log(res.appid);

      authorizationNumber.value = res.appid;
      versions.value = res.costPlanName
    })
    .catch((err: any) => {
      throw new Error(err);
    });
};

const goWebsite = () => {
  getLicenseData();
  isVisible.value = true;
};

const buttonMessage = () => {
  openWeb();
};
// 跳转官网
const openWeb = () => {
  window.open(tableData.value.homePage);
};

//onmounted
onMounted(() => {
  getTableData();
});
</script>
<style lang="scss" scoped>
.systemInfo {
  width: 100%;
  height: calc(100% - 72px);
  padding: 16px;
  background-color: #fff;
  overflow-y: scroll;
  .table {
    width: 800px;
    height: 570px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    .data {
      display: flex;
      width: 100%;
      height: 100%;
      ul {
        width: 176px;
        overflow: hidden;
        li {
          font-size: 14px;
          padding-left: 23px;
          width: 100%;
          height: 57px;
          line-height: 56px;
          border-bottom: 1px solid rgba(0, 0, 0, 0.06);
          background-color: #ffffff;
          a {
            margin-left: 32px;
          }
          &:nth-last-child(1) {
            border-top: 0;
            border-bottom: 0;
          }
        }
        .left-li {
          padding-left: 0;
          padding-right: 24px;
          width: 176px;
          text-align: right;
          background-color: #fafafa;
          border-right: 1px solid rgba(0, 0, 0, 0.06);
        }
      }
      .table-right {
        width: 624px;
        .productName {
          display: flex;
          align-items: center;
          img {
            width: 26px;
            height: 25px;
            margin-left: 8px;
          }
        }
      }
    }
  }
}
.model {
  display: flex;
  align-items: center;
  .logo {
    width: 160px;
    height: 160px;
    margin-left: 11px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .info {
    margin-left: 24px;
    margin-top: 8px;
    .title {
     // width: 223px;
      height: 30px;
      font-size: 30px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: rgba(0, 0, 0, 0.85);
      line-height: 30px;
    }
    .item {
      margin-top: 20px;
      font-size: 14px;
      span {
        margin-left: 12px;
      }
      a {
        margin-left: 12px;
      }
    }
  }
}
</style>
